#!/bin/bash

rm -rf  /home/mysql/backup/$(date +%Y_%m_%d --date='1 days ago')*.sql.gz

cd /home/mysql/backup/
/usr/local/mysql/bin/mysqldump -u root -Q -R --port=3306 --socket=/data/commentdb_3306/mysql.sock  comment3306 > /home/mysql/backup/`date +'%Y_%m_%d'`comment3306.sql
gzip `date +'%Y_%m_%d'`comment3306.sql;

/usr/local/mysql/bin/mysqldump -u root -Q -R --port=3307 --socket=/data/commentdb_3307/mysql.sock  comment3307 > /home/mysql/backup/`date +'%Y_%m_%d'`comment3307.sql
gzip `date +'%Y_%m_%d'`comment3307.sql;

/usr/local/mysql/bin/mysqldump -u root -Q -R --port=3308 --socket=/data/commentdb_3308/mysql.sock  comment3308 > /home/mysql/backup/`date +'%Y_%m_%d'`comment3308.sql
gzip `date +'%Y_%m_%d'`comment3308.sql;



#for i in `seq 1 1 16`; 
for i in `perl -e 'for(1..16) {printf "%02d\n",$_;}'`;
do 

/usr/local/mysql/bin/mysqldump -u root -Q -R --port=3309 --socket=/data/commentdb_3309/mysql.sock  comment_${i} > /home/mysql/backup/`date +'%Y_%m_%d'`comment3309_${i}.sql;
gzip `date +'%Y_%m_%d'`comment3309_${i}.sql;

done
